package com.projecy.config.security;

import com.projecy.config.filter.JwtAuthorizationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;


public class JwtConfigurerAdapter extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {



    @Autowired
    JwtAuthorizationFilter jwtAuthorizationFilter;

//    private final JwtAuthorizationFilter jwtAuthorizationFilter;

    public JwtConfigurerAdapter(JwtAuthorizationFilter jwtAuthorizationFilter){
        this.jwtAuthorizationFilter = jwtAuthorizationFilter;
    }

    @Override //JWT接管HttpSecurity
    public void configure(HttpSecurity httpSecurity){
        System.out.println("JWT接管HttpSecurity");
        httpSecurity.addFilterBefore(jwtAuthorizationFilter, UsernamePasswordAuthenticationFilter.class);
    }
}
